//
//  GNRBLEFriendsManager.h
//  Faceto
//
//  Created by LvYuan on 2017/4/26.
//  Copyright © 2017年 LvYuan. All rights reserved.
//

/**
 这个类用来管理蓝牙用户
 */

#import "GNRObject.h"
#import "GNRBLEFriendModel.h"
#import "GNRBLECentralManager.h"//中心
#import "GNRBLEPeripheralManager.h"//外设
#import "GNRDataStore.h"

typedef void(^GNRBLESubscribeBlock)(GNRPeripheral*peripheral,NSError *error);
typedef void(^GNRBLEReadProfileInfoBlock)(GNRPeripheral*peripheral,id result,NSError *error);
typedef void(^GNRBLEFriendsChangeBlock)(NSMutableArray <GNRBLEFriendModel *> *friends ,NSError *error);//连接好友数量、信息改变

@interface GNRBLEFriendsManager : GNRObject
@property (nonatomic, assign)BOOL blueToothOpen;//是否开启了多人模式
@property (nonatomic, copy)GNRBLESubscribeBlock subBlock;
@property (nonatomic, copy)GNRBLEReadProfileInfoBlock readBlock;
@property (nonatomic, copy)GNRBLEConnectBlock connectBlock;
@property (nonatomic, copy)GNRBLEDisConnectBlock disConnetBlock;
@property (nonatomic, copy)GNRBLEFriendsChangeBlock friendsChangeBlock;

@property (nonatomic, strong)NSMutableArray <GNRBLEFriendModel *>* connectFriends;//正在连接的好友

+ (instancetype)manager;

//开始扫描
- (void)startScanWithScanCompletion:(GNRBLEScanSucceeBlock)block
                              error:(GNRBLEScanErrorBlock)errorBlock;

/**
 连接设备 并扫描该的服务及特征 并订阅 和 读取内容
 */
- (void)connectForPeripheral:(GNRPeripheral *)connectPeripheral
             readProfileInfo:(GNRBLEReadProfileInfoBlock)readBlock
                   subscribe:(GNRBLESubscribeBlock)subscribeBlock;

//取消订阅 
- (void)unSubscribe:(GNRPeripheral *)connectPeripheral
          subscribe:(GNRBLESubscribeBlock)subscribeBlock;

//停止扫描
- (void)stopScan;

//开启外设广播
- (void)openPeripheralService;
//关闭
- (void)closePeripheralService;
@end
